//
//  XMTestModel.swift
//  AnneKit-Swift
//
//  Created by 宁小陌 on 2021/2/4.
//  Copyright © 2021 宁小陌. All rights reserved.
//

import Foundation
import SwiftyJSON

struct XMTestModel {

    let code: Int
    let list: [ListBaseModel]
    let detail_address : DetailAddressModel
    
    // 这里面积area中就不能再用arrayValue获取了，因为arrayValue获取的为JSON类型，我们需要转为我们需要的对象
//    init(jsonData: JSON) {
//        self.code = jsonData["code"].intValue
//        self.list = ListBaseModel(jsonData: jsonData["list"])
//        self.detail_address = DetailAddressModel(jsonData: jsonData["detail_address"])
//    }
    
//    struct ListBaseModel : Codable {
//        var userID: String?
//        var date: String?
//        var idx: String?
//        var content: String?
//
//        init(jsonData: JSON) {
//            userID  = jsonData["userID"].stringValue
//            date    = jsonData["date"].stringValue
//            idx     = jsonData["idx"].stringValue
//            content = jsonData["content"].stringValue
//        }
//    }
}


struct DetailAddressModel {
    var province: String?
    var city: String?
    var district: String?
    var street: String?
    
    init(jsonData: JSON) {
        self.province   = jsonData["province"].stringValue
        self.city       = jsonData["city"].stringValue
        self.district   = jsonData["district"].stringValue
        self.street     = jsonData["street"].stringValue
    }
    
}

struct ListBaseModel {
    var userID: String?
    var date: String?
    var idx: String?
    var content: String?

    init(jsonData: JSON) {
        userID  = jsonData["userID"].stringValue
        date    = jsonData["date"].stringValue
        idx     = jsonData["idx"].stringValue
        content = jsonData["content"].stringValue
    }
}
